package com.lanren.demo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;

import com.lanren.hovertitlerecylerview.HoverTitleItemDecoration;
import com.lanren.hovertitlerecylerview.HoverTitleRecyclerView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private HoverTitleRecyclerView mHoverTitleRecyclerView;
    private HoverAdapter mAdapter;
    private List<GroupBean> groupBeanList = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mHoverTitleRecyclerView = findViewById(R.id.recycler_view);
        mHoverTitleRecyclerView.setLayoutManager(new LinearLayoutManager(this));

        setData();
        mAdapter = new HoverAdapter(this, groupBeanList);
        mHoverTitleRecyclerView.setAdapter(mAdapter);
        mHoverTitleRecyclerView.addItemDecoration(new HoverTitleItemDecoration());

        mHoverTitleRecyclerView.setmOnHoverTitleListener(new HoverTitleRecyclerView.OnHoverTitleListener() {
            @Override
            public void onHoverTitleClick(int adapterPosition) {

            }

            @Override
            public void onHoverTitleSelection(int adapterPosition) {

            }
        });
    }

    private void setData() {
        for (int i = 0; i < 10; i++) {
            groupBeanList.add(new GroupBean(true, "购物" + i));
            groupBeanList.add(new GroupBean(false, "住房" + i));
            groupBeanList.add(new GroupBean(false, "电费" + i));
            groupBeanList.add(new GroupBean(false, "交通" + i));
            groupBeanList.add(new GroupBean(false, "餐饮" + i));
            groupBeanList.add(new GroupBean(false, "娱乐" + i));
        }
    }
}
